package com.bbz.core.sort;

public class Person implements Comparable<Person> {

	private String name;
	private int age;

	public Person(String name, int age) {
		this.name = name;
		this.age = age;
	}

	public Person() {
		this("unknown", 0);
	}

	// 重写该类的compareTo()方法，使其按照从小到大顺序排序
	@Override
	public int compareTo(Person o) {
		return age - o.age; // return o.age-age; 从大到小顺序排序

	}

	// 重写Student类的toString()方法，在输入对象时按照以下方式输出
	@Override
	public String toString() {
		return "Person[name:" + name + ",age:" + age + "]";
	}

}
